<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>

    // 自定义三维数组
    var testArr = [[1,2,3],4,5,[6],7,[[8],[9]]]

    // 方法一：递归
    var res = [];// 存放结果
    function toArr(arr){
      arr.forEach(element => {
        if(Array.isArray(element)){
          toArr(element)
        }else{
          res.push(element)
        }
      });
      return res
    }
    toArr(testArr)
    res.push(10)
    console.log(res,testArr);


    // 将数组转换成字符串在转成一维数组
    // 方法二：join + split 方法  toString() + split
    var str = testArr.join(',')
    var arr = str.split(',')
    var res = arr.map(Number)
    console.log(res);
  </script>
</body>
</html>